﻿using System.Collections.Generic;
using System.Linq;

namespace HQS.TokenInterpolation.Tokens
{
    [Token(Name = "avg")]
    public class Average : Sum
    {
        protected override TokenRuntimeValue OnAccept(IDataSourcesVisitor dataSourcesVisitor)
        {
            return dataSourcesVisitor.Visit(this);
        }

        public override double Aggregate(List<double> result)
        {
            return result.Average();
        }
    }
}